/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dbbeans;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Laur
 */
@Entity
@Table(name = "fields", catalog = "wad", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Fields.findAll", query = "SELECT f FROM Fields f"), // NQ used to select all the fields
    @NamedQuery(name = "Fields.findById", query = "SELECT f FROM Fields f WHERE f.id = :id"), // NQ used to select a field by id
    @NamedQuery(name = "Fields.findByName", query = "SELECT f FROM Fields f WHERE f.name = :name"), // NQ used to select  fields by name
    @NamedQuery(name = "Fields.findByType", query = "SELECT f FROM Fields f WHERE f.type = :type"), // NQ used to select  fields by type
    @NamedQuery(name = "Fields.findByNode", query = "SELECT f FROM Fields f WHERE f.node = :node")}) // NQ used to select fields by node
public class Fields implements Serializable {
    // definition of the bean by adnotations
    private static final long serialVersionUID = 1L; 
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY) // id is auto incremented
    @Basic(optional = false)
    @NotNull
    @Column(name = "id", nullable = false)
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "name", nullable = false, length = 50)
    private String name;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 2147483647)
    @Column(name = "value", nullable = false, length = 2147483647)
    private String value;
    @Basic(optional = false)
    @NotNull
    @Column(name = "type", nullable = false)
    private int type;
    @Basic(optional = false)
    @NotNull
    @Column(name = "node", nullable = false)
    private int node;

    // constructors used to create a new instance of this bean
    public Fields() {
    }

    public Fields(Integer id) {
        this.id = id;
    }

    public Fields(Integer id, String name, String value, int type, int node) {
        this.id = id;
        this.name = name;
        this.value = value;
        this.type = type;
        this.node = node;
    }

    // GETTERS AND SETTERS
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public int getNode() {
        return node;
    }

    public void setNode(int node) {
        this.node = node;
    }

    // AUTO GENERATED hashCode() and equals()
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Fields)) {
            return false;
        }
        Fields other = (Fields) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "dbbeans.Fields[ id=" + id + " ]";
    }
    
}
